package cn.zb.controller;

import cn.zb.api.user.feign.UserFeign;
import cn.zb.common.util.Result;
import cn.zb.entity.SysMenu;
import cn.zb.service.SysMenuService;
import cn.zb.vo.MenuVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("menu")
public class MenuController {
    @Resource
    SysMenuService menuService;
    @Resource
    UserFeign userFeign;

    @RequestMapping("list")
    public List<MenuVO> list(String yhm){
        Result<List<Integer>> result = userFeign.roleMenu(yhm);

        return menuService.initMenu(result.getData());
    }

    // 加载所有组件的路由地址
    @RequestMapping("router")
    public List<SysMenu> router(){
        QueryWrapper<SysMenu> qw = new QueryWrapper<>();
        qw.eq("menu_type","C");
        qw.select("menu_name","path","component");
        List<SysMenu> list = menuService.list(qw);
        return list;
    }
}
